package org.gten.gegedexin.service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.gten.gegedexin.pojo.DraftPojo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ReadDraft {
    @Autowired
    DraftServiceImpl draftService;

    public JSONObject readDraft(String mailID){
        DraftPojo draft = draftService.getDraftById(Integer.parseInt(mailID));
        JSONObject json = new JSONObject();
        json.put("draftID",draft.getDraftId());
        json.put("sender",draft.getSender());
        json.put("receiver",draft.getReceiver());
        json.put("hender",draft.getHeader());
        json.put("context",draft.getContext());
        json.put("editTime",draft.getEditTime().toString());
        return json;
    }
}
